CLIからHTMLファイルをlocalhostでweb broserに表示する
deno_std/http/file-serverを使う
閲覧したいdirectoryで↓を実行する
$ deno run --allow-net --allow-read jsr:@std/http/file-server
from https://jsr.io/@std/http#file-server
framworkを使う
servestを使ってlocalhostを立てる
閲覧したいdirectoryで↓を実行する
$ deno run --allow-net=0.0.0.0:8899 --allow-read=./ https://scrapbox.io/api/code/takker/CLIからHTMLファイルをlocalhostでweb_broserに表示する/script.ts
code:script.ts
import { createApp, serveStatic } from "https://deno.land/x/servest@v1.3.1/mod.ts";
const app = createApp();
app.use(serveStatic("./"));
const port = 8899;
app.listen({ port });
console.log(open http://localhost:${port});
HTMLの雛形
code:index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>local server page</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div id="main"></div>
<script src="./index.js" type="module"></script>
</body>
</html>
HTML+CSS+Javascriptを簡単に試す
#2024-08-24 12:25:45
#2021-08-10 11:01:02
#2021-06-16 10:56:43